<template>
    <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>热菜</el-breadcrumb-item>
        <el-breadcrumb-item>炒</el-breadcrumb-item>
        
    </el-breadcrumb>

        <el-card class="box-card">
            
        <el-row :gutter="20">
            <el-col :span="8">
                <el-input placeholder="请输入内容"  class="input-with-select">
                <el-button slot="append" icon="el-icon-search"></el-button>
            </el-input>
            </el-col>
            <el-col :span="4">
                <el-button type="primary">添加菜品</el-button>
        </el-col>
        </el-row>

        <!-- 菜单列表的表格 -->
         <el-table
            :data="courseList"
            border
            stripe
            style="width: 100%">
            <el-table-column type="index"></el-table-column>
                <el-table-column prop="course_name" label="菜品名称"></el-table-column>
                <el-table-column prop="user_name" label="作者姓名"></el-table-column>
                <el-table-column prop="course_taste" label="菜色特点"></el-table-column>
                <el-table-column prop="course_ischarge" label="菜品状态">
                   <template slot-scope="scope">
                       <el-switch v-model="scope.row.course_ischarge"></el-switch>
                   </template>
                </el-table-column>
                <el-table-column label="操作">
                     <template slot-scope="scope">
                         
                         <el-button type="primary" icon="el-icon-edit" size="small" @click="editCourse(scope.row.course_id)"></el-button>
                         <el-button type="danger" icon="el-icon-delete" size="small" @click="delCourse(scope.row.course_id)"></el-button>
                     </template>
                </el-table-column>
         </el-table>

                 <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="queryInfo.page"
                    :page-sizes="[1, 2, 3, 4, 5]"
                    :page-size="queryInfo.limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="tolat">
                </el-pagination>

        </el-card>

    </div>
</template>

<script>
export default {
    data(){
        return{
            queryInfo:{
                page:1,
                limit:5
            },
            courseList:[],
            tolat:0
        }
    },
    created(){
        this.getCourseList()
    },
    methods:{
        getCourseList(){
            this.$axios.post("course/index",this.queryInfo).then(res =>{
                if(res.data.code !=1) return this.$message.error(res.data.msg);
                this.courseList = res.data.data;
                this.tolat = 6
                console.log(this.courseList)
            })
            
        },
        handleSizeChange(newSize){
            this.queryInfo.limit = newSize;
            this.getCourseList();
        },

        handleCurrentChange(newPage){
            this.queryInfo.page = newPage;
            this.getCourseList()
        }
    }
    
}
</script>

<style lang="less" scoped>
    
</style>